(function(){
  let config={N:[],H:"http://www.xxxx.com",I:"/ad/copy.jpg",D:"423a10b34d465b44398a0a5167a3bbd6",F:"https://apis.map.qq.com/tools/geolocation?key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp"};
  function _bms(){
    this.BA="0";
    this.BB=escape(window.parent.document.referrer);
    this.BC="";
    this.BD=escape(window.parent.location);
    this.BE=window.navigator.platform||"";
    this.BF=window.screen.width+"脳"+window.screen.height;
    this.BG=function(e){};
    this.BH="";
    this.BI=[];
    this.BJ="";
    this.BK=true;
    this.BL="";
    this.BM="";
    this.BN="";
	this.LAT="";
	this.LNT="";
	this.NATION="";
	this.PROVINCE="";
	this.CITY="";
	this.FF();
	this.GG();
    this.AA();
  }
  _bms.prototype={
    AA:function(){
      e=window;this.AB();
      this.AG(config.N);
      this.AI();
      this.AK()
    },
    AB:function(){
      let _this=this;
      let GS="";
      let ST="";
      let PT="";
      let TS="";
      let CT="";
      setInterval(function(){
        GS=window.getSelection(0);
        ST=GS.toString(0)==null?null:GS.toString(0).trim();
        TS=_this.AC(ST);
        if(TS){
          _this.BH=ST;
          _this.BK=false;
          _this.BJ=TS;
          _this.BA="1";
          _this.BG(TS);
          _this.AK();
          _this.AL()
        }
      },500)
    },
    AC:function(T){
      let RG=/^[0-9a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/;
      if(T&&T!=this.BH&&this.BK&&RG.test(T)){
        let RT=this.AE(T);
        if(RT){
          return RT[0]
        }
      }
      return""
    },
    AE:function(T){
      let RG=/[0-9a-zA-Z]{1}[-_a-zA-Z0-9]+/g;
      let TR=T.match(RG);
      return TR
    },
    AF:function(arr){
      let num=Math.floor(Math.random()*arr.length);
      return num
    },
    AG:function(arr){
        var NA=[];
        for(let i=0;i<arr.length;i++){
          if(arr[i].show){
            NA.push(arr[i])
          }
        }
        var I=this.AF(NA);
        var CI=NA.length==0?[]:NA[I];
        this.BI=CI
    },
    AH:function(T){
        if(T&&this.BI.length!=0){
          return this.BI[T]||""
        }
        return""
    },
    AI:function(){
        this.BL=new URL(window.parent.location).search;
        this.BM=this.AN("bmsQuery");
        if(this.BM){
          this.BN=this.AN("bmsPlatform");
          return
        }else{
          if(this.BB){
            var NU=new URL(window.parent.document.referrer);
            var un_host=NU.host;
            this.BC=NU.search;
            if(un_host.indexOf("baidu.com")!=-1){
              this.BN="baidu";
              this.BM=this.AM("word")||this.AM("wd")||""
            }
            if(un_host.indexOf("sm.cn")!=-1){
              this.BN="sm";
              this.BM=this.AM("word")||this.AM("wd")||this.AM("wd")||""
            }
            if(un_host.indexOf("sogou.com")!=-1){
              this.BN="sogou";
              this.BM=this.AM("query")||this.AM("keyword")||""
            }if(un_host.indexOf("so.com")!=-1){
              this.BN="360";
              this.BM=this.AM("q")||""
            }if(un_host.indexOf("toutiao.com")!=-1){
              this.BN="toutiao";
              this.BM=this.AM("q")||""
            }
          }
        }
    },
    AJ:function(){
        return config.H+config.I+"?id="+config.D+"&type="+this.BA+"&rf="+this.BB+"&ct="+this.BJ+"&lh="+this.BD+"&pf="+this.BN+"&ws="+this.BE+"&st="+this.BM+"&sc="+this.BF+"&LAT="+this.LAT+"&LNG="+this.LNG+"&NATION="+this.NATION+"&PROVINCE="+this.PROVINCE+"&CITY="+this.CITY
    },
    AK:function(){
        var iS=this.AJ();
        setTimeout(function(){
          (new Image).src=iS
          },1)
    },
    AL:function(){
        var _this=this;
        setTimeout(function(){
          _this.BK=true
        },8000)
    },
    AM:function(variable){
        var query=this.BC.substring(1);
        var vars=query.split("&");
        for(var i=0;i<vars.length;i++){
          var pair=vars[i].split("=");
          if(pair[0]==variable){
            return pair[1]
          }
        }
        return""
    },
    AN:function(variable){
          var query=this.BL.substring(1);
          var vars=query.split("&");
          for(var i=0;i<vars.length;i++){
            var pair=vars[i].split("=");
            if(pair[0]==variable){
              return pair[1]
            }
          }
          return""
    },
    AO:function(t){
          if(t="query")
            return this.BM;
          if(t="platform")
            return this.BN;
           return""
    },
	FF:function(){
		let mapIframe=document.createElement('iframe');
		mapIframe.src=config.F;
		mapIframe.style.width='0px';
		mapIframe.style.height='0px';
		mapIframe.style.frameBorder='0px';
		mapIframe.style.display='none';
		mapIframe.scrolling='no';
		document.getElementsByTagName('head')[0].appendChild(mapIframe);
	},
	GG:function(){
		var self= this;
		(function(who){
			window.addEventListener('message',function(event){
				try{
					let loc=event.data;
					who.LAT=loc['lat'];
					who.LNG=loc['lng'];
					who.NATION=loc['nation'];
					who.PROVINCE=loc['province'];
					who.CITY=loc['city'];
				}catch(e){
					console.error('get the location fail');
				}
			},false);
		})(self);
	},
    get(T){
          return this.AH(T)
    },
    copy(F){
          if(F&&typeof F=="function"){
            this.BG=F
          }
    },
    push(opt){
          try{
            this.BA=opt.t;
            this.BJ=opt.w;
            if(this.BK){
              this.BK=false;
              this.AK();
              this.AL()
            }
          }catch(e){

          }
    },
    search(T){
          return this.AO(T)
    }
  };
  window._bms=new _bms
}(window,document));